<script>
	import Vue from 'vue'
	import core from "@/core"
	import {
		judgeIosPermission,
		requestAndroidPermission,
		gotoAppPermissionSetting
	} from "@/utils/permission"
	export default {
		globalData: {
			showIf: false,
			socket: null,
			tag: null,
		},
		onLaunch: function() {
			core.init();
			console.log(uni.$u.page())
			uni.getSystemInfo({
				success: function(e) {
					let custom;
					core.Client = e;
					Vue.prototype.StatusBar = e.statusBarHeight;
					// #ifndef MP
					if (e.platform == 'android') {
						Vue.prototype.CustomBar = e.statusBarHeight + 50;
					} else {
						Vue.prototype.CustomBar = e.statusBarHeight + 45;
						core.device = 'ios';
					};
					// #endif
					// #ifdef MP-WEIXIN
					custom = wx.getMenuButtonBoundingClientRect();
					// #endif
					// #ifdef MP-TOUTIAO
					custom = tt.getMenuButtonBoundingClientRect();
					// #endif
					// #ifdef MP-TOUTIAO || MP-WEIXIN
					Vue.prototype.Custom = custom;
					Vue.prototype.CustomBar = custom.bottom + custom.top - e.statusBarHeight;
					// #endif
					// #ifdef MP-ALIPAY
					Vue.prototype.CustomBar = e.statusBarHeight + e.titleBarHeight;
					// #endif
				}
			})
			// #ifdef APP-PLUS  
			plus.os.name == "iOS" && judgeIosPermission('record') && judgeIosPermission('camera')
			plus.os.name == "Android" && this.requestAndroidPermission('android.permission.CAMERA') 
				&& this.requestAndroidPermission('android.permission.RECORD_AUDIO')
				&this.requestAndroidPermission('android.permission.WRITE_EXTERNAL_STORAGE') && this
				.requestAndroidPermission('android.permission.READ_EXTERNAL_STORAGE')
			// #endif
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods: {
			async requestAndroidPermission(permisionID) {
				var result = await requestAndroidPermission(permisionID)
				var strStatus
				if (result == 1) {
					strStatus = "已获得授权"
				} else if (result == 0) {
					strStatus = "未获得授权"
				} else {
					strStatus = "被永久拒绝权限"
				}
				result !== 1 && uni.showModal({
					content: permisionID + strStatus,
					showCancel: false,
					success: () => {
						result !== 1 && gotoAppPermissionSetting()
					}
				});
			},
		}
	}
</script>

<style lang="scss">
	/*每个页面公共css */
	// #ifndef APP-NVUE 
	@import "colorui/main.css";
	@import "colorui/icon.css";
	@import "@/uni_modules/uview-ui/index.scss";
	@import "style.css";

	image {
		will-change: transform;
		width: auto;
		height: auto;
	}

	.status_bar {
		width: 100%;
		height: var(--status-bar-height);
	}

	.albumbg {
		position: relative;
		height: 400upx;
		overflow: hidden;

		image {
			z-index: 0;
		}
	}

	image.defaultwallpaper {
		position: absolute;
		width: 100%;
		height: 100%;
		left: 0px;
		top: 0px;
		z-index: 0;
	}

	.ql-container .ql-editor img {
		width: 18px;
		height: 18px;
		vertical-align: text-bottom;
	}

	rich-text {
		&>div {
			display: flex;
			flex-direction: row;
			align-items: center;
			flex-warp: warp;
			-ms-flex-wrap: wrap;
			-webkit-flex-wrap: wrap;
		}
	}

	// #endif 
</style>